package com.wwg.cms.service.impl;

import java.util.Collection;
import com.wwg.cms.bo.*;
import com.wwg.cms.service.*;
import com.css.framework.dao.GeneralDao;

import com.wwg.cms.bo.entity.*;

/**
 * 
 * create by wwl
 * 文章表
 * @author wwl
 */
public class DocumentServiceImpl implements DocumentService{

    private GeneralDao generalDao;
      
    public void setGeneralDao(GeneralDao generalDao) {
	        this.generalDao = generalDao;
	}
    
   
    
    /**
	 *获取所有文章表
	 */
	public Collection getDocumentList(){
     String hsql="select ent from DocumentEntity as ent ";
     return generalDao.find(hsql);
    
    }
	
	/**
	 * 添加文章表
	 * @param document 文章表
	 * @return
	 */
	public Document addDocument(Document document){
   
			generalDao.save(document);
		    
    return document;
    
    }
	
	/**
	 * 修改文章表
	 * @param document 文章表
	 * @return
	 */
	public  Document updateDocument(Document document){
    
            generalDao.saveOrUpdate(document); 
	
        
        return document;
    }
	
	/**
	 * 删除文章表
	 * @param document 文章表
	 * @return
	 */
	public Document deleteDocument(Document document){
      		generalDao.delete(document);
		
        return document;
    }
    
    /**
     *  获取文章表 by id
     *  @param id 编号
     * @return
	 */
    public Document getDocumentById(Long id){
    
   
     return (Document)generalDao.fetch(id,DocumentEntity.class);
    
    }
    
}
